<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"> </div>
  <script>
    //定义一个全局变量，触发者
    const obj = { name: 'xiaopang' }
    //定义一个函数，引用obj变量，响应者
    function effect() {
      app.innerHTML = obj.name
    }

    effect()

    setTimeout(() => {
      obj.name = 'xxp'
      //手动执行effect 函数
      effect()
    }, 1000)
  </script>
</body>

</html>